import 'package:shared_preferences/shared_preferences.dart';

class Storage{

  static Future<void> setString(key,value) async{
    SharedPreferences sp=await SharedPreferences.getInstance();
    sp.setString(key, value);
  }
  //新版shared_preferences增加了可空类型 ，返回类型需要定义成 Future<String?> 的可空类型
  static Future<String?> getString(key) async{
    SharedPreferences sp=await SharedPreferences.getInstance();
    return sp.getString(key);
  }
  static Future<void> remove(key) async{
    SharedPreferences sp=await SharedPreferences.getInstance();
    sp.remove(key);
  }
  static Future<void> clear() async{
    SharedPreferences sp=await SharedPreferences.getInstance();
    sp.clear();
  }
}